#include "../../include/tools/Timer.hpp"
using namespace klas;
using namespace tools;

Timer::Timer()
{
  // windows
  #ifdef KLAS_WINDOWS
  QueryPerformanceFrequency(&m_frequency);
  m_start.QuadPart = 0;
  m_stop.QuadPart = 0;
  #endif

  // start the timer
  restart();
}

void Timer::restart()
{
  // windows
  #ifdef KLAS_WINDOWS
  QueryPerformanceCounter(&m_start);
  #endif
}

double Timer::getSeconds()
{
  // windows
  #ifdef KLAS_WINDOWS
  QueryPerformanceCounter(&m_stop);
  return ((double) (m_stop.QuadPart - m_start.QuadPart) / (double)(m_frequency.QuadPart));
  #endif
}

double Timer::getMilliseconds()
{
  return getSeconds() * 1000.0;
}